package com.live.dengdengtv;

import android.app.Application;
import android.net.Uri;
import android.test.ApplicationTestCase;
import android.util.Log;

import com.google.gson.Gson;
import com.live.dengdengtv.bean.SimpleInfoMap;
import com.live.dengdengtv.bean.gson.ConversationCard;
import com.live.dengdengtv.bean.gson.ConversationSp;
import com.live.dengdengtv.net.DianboNetTask;
import com.live.dengdengtv.utils.DianboSignUtils;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.util.Observable;
import java.util.Observer;
import java.util.TreeMap;

/**
 * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
 */
public class ApplicationTest extends ApplicationTestCase<Application> {
    public ApplicationTest() {
        super(Application.class);
    }


    public void testGson(){
        ConversationSp conversationSp = new ConversationSp();
        ConversationCard currCard = new ConversationCard();
        currCard.lastMsg = "金佛空数据";
        conversationSp.conCardList.add(currCard);

        String conJson = new Gson().toJson(conversationSp,ConversationSp.class);
        Log.e(ApplicationTest.class.getName(),"ApplicationTest-json = "+conJson);
    }

    public void testSignss(){


//        DianboNetTask.getCategoryList();
//        Log.e("testMySign", end);
    }
    public void testMySign(){
        String ss = "GETvod.api.qcloud.com/v2/index.php?Action=DescribeClass&Nonce=578042233&Region=gz&SecretId=AKIDzseMyQzrAYnRxJdqMuhTk0fIGazJk2Rj&Timestamp=1475782213";

        String end = DianboSignUtils.signStr(ss,DianboNetTask.secretkey);
        Log.e("testMySign", end);
    }




    public void test2(){
        Uri imageUrl = Uri.parse("D:\\work-wyf\\开发工具\\error.log");
        System.out.println("开发来上课皮肤");
        System.out.println(imageUrl.getPath());
        System.out.println(new File(imageUrl.getPath()).getName());
    }

    public void test1(){
        String ss = "{\"result\":0,\"message\":\"SUCCESS\",\"data\":{\"user_id\":\"1000000\"}}";
        SimpleInfoMap baseInfoBean = new Gson().fromJson(ss, SimpleInfoMap.class);
        System.out.println("空数据佛山房");
        System.out.println(baseInfoBean.message);
        System.out.println(baseInfoBean.data);
    }

    public void testJson(){

        JSONObject inviteCmd = new JSONObject();
        try {
            inviteCmd.put("userAction", "SSSS");
            inviteCmd.put("actionParam", "DDD");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        String cmds = inviteCmd.toString();
        System.out.println(cmds);
        Log.e("pplicationTest",cmds);

        try {
            JSONObject bb = new JSONObject(cmds);
            Log.e("pplicationTest",bb.getString("actionParam"));

        } catch (JSONException e) {
            Log.e("pplicationTest","JSONException");
            e.printStackTrace();
        }
    }


}